package com.framework2.utils;

import android.content.Context;

import java.io.InputStream;
import java.util.List;

/**
 * 解析excel文件
 *
 * @author Yangjie
 *         className ParseExcelUtil
 *         created at  2017/4/20  12:40
 */
public class ParseExcelUtil {
    private static volatile ParseExcelUtil singleton;

    private ParseExcelUtil() {
    }

    public static ParseExcelUtil getInstance() {
        if (singleton == null) {
            synchronized (ParseExcelUtil.class) {
                if (singleton == null) {
                    singleton = new ParseExcelUtil();
                }
            }
        }
        return singleton;
    }

    public void parseEE(List list) {

    }
    /**
     * 读取excel数据到数据库里
     * @param context context
     */
    private void readExcelToDB(Context context) {
        try {
            InputStream is = context.getAssets().open("syncenglish_extra_voice_data.xls");
//            Workbook book = Workbook.getWorkbook(is);
//            book.getNumberOfSheets();
//            // 获得第一个工作表对象
//            Sheet sheet = book.getSheet(0);
//            int Rows = sheet.getRows();
//            ExtraVoiceInfo info = null;
//            for (int i = 1; i < Rows; ++i) {
//                String content = (sheet.getCell(0, i)).getContents();
//                String phonetic = (sheet.getCell(1, i)).getContents();
//                String property = (sheet.getCell(2, i)).getContents();
//                String paraphrase = (sheet.getCell(3, i)).getContents();
//                String usVoiceName = (sheet.getCell(4, i)).getContents();
//                String ukVoiceName = (sheet.getCell(5, i)).getContents();
//
//                info = new ExtraVoiceInfo(content, phonetic, property, paraphrase, usVoiceName, ukVoiceName);
//                saveInfoToDataBase(info);
//            }
//            book.close();
//            PreferencesUtils.putBoolean(context, ConstData.IS_READED_EXTRA_SOUND_DATA, false);
        } catch (Exception e) {
//            PreferencesUtils.putBoolean(context, ConstData.IS_READED_EXTRA_SOUND_DATA, true);
//            Log.e(TAG, EXCEPTION, e);
        }
    }
}
